﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SurfaceArtillery
{
    class Missile
    {
        private int destructionCoef = 400000;

        private Vector2 location;
        private float weight;
        private float power;
        private float rotation;
        private int damage;
        private int cost;
        private Vector2 velocity;
        private Vector2 force = Vector2.Zero;
        private bool flaggedForDeletion = false;
        private Texture2D texture;


        public Texture2D Texture { get { return texture; } set { texture = value; } }
        public Vector2 Location
        {
            get { return location; }
            set { location = value; }
        }
        public float Weight
        {
            get { return weight; }
            set 
            { 
                weight = value;
                damage = (int)Math.Round(weight * destructionCoef);
            }
        }
        public float Power
        {
            get { return power; }
            set 
            { 
                power = value;
                calcCost();
            }
        }
        public Vector2 Velocity
        {
            get { return velocity; }
            set { velocity = value; }
        }
        public float Rotation
        {
            get { return rotation; }
            set { rotation = value; }
        }
        public int Damage
        {
            get { return damage; }
        }
        public int Cost
        {
            get { return cost; }
        }
        public Vector2 Force
        {
            get { return force; }
            set { force = value; }
        }
        public bool FlaggedForDeletion
        {
            get { return flaggedForDeletion; }
            set { flaggedForDeletion = value; }
        }

        private void calcCost()
        {
            cost = (int)Math.Round(power * power * 500);
        }

        public Missile(Vector2 loc, float weight, float power, Vector2 vel, float rot)
        {
            this.location = loc;
            this.weight = weight;
            this.power = power;
            this.velocity = vel;
            this.rotation = rot;

            damage = (int)Math.Round(weight * destructionCoef);
            calcCost();
        }
        public Missile(Vector2 loc, float weight, float power, Vector2 vel, float rot, Texture2D tex)
        {
            this.location = loc;
            this.weight = weight;
            this.power = power;
            this.velocity = vel;
            this.rotation = rot;
            texture = tex;

            damage = (int)Math.Round(weight * destructionCoef);
            calcCost();
        }
    }
}
